
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObject;
using DataAccessLayer;

namespace BusinessLogic
{
    /// <summary>
    /// Define SubCategoryUtil class. This class user for BussinessLayer.

    /// </summary>
    public class SubCategoryUtil
    {
        /// <summary>
        /// Define function Insert for SubCategory Object.
        /// </summary>
        /// <param name="t">object data need Insert.</param>
        /// <returns>
        ///    True: if insert successfull.
        ///    False: if insert error.
        ///</returns>
        public static bool Insert(SubCategory t)
        {
           // BizObject.PurgeCacheItems("SubCategory");

            return SubCategoryDao.Insert(t);
        }
        /// <summary>
        /// Define function Update for SubCategory Object.
        /// </summary>
        /// <param name="t">project data need updated.</param>
        /// <returns>
        ///    True: if update successful.
        ///    False: if update Error.
        ///</returns>
        public static bool Update(SubCategory t)
        {
            //BizObject.PurgeCacheItems("SubCategory");

            return SubCategoryDao.Update(t);
        }
        /// <summary>
        /// Get All SubCategory object from table SubCategory.
        /// </summary>
        /// <returns>List SubCategory object.</returns>
        public static List<SubCategoryResult> GetAll()
        {
            List<SubCategoryResult> obj = null;
            //string key = "SubCategory_GetAll";
            //if (BizObject.Cache[key] != null)
            //{
            //    obj = (List<SubCategoryResult>)BizObject.Cache[key];
            //}
            //else
            //{
                obj = SubCategoryDao.GetAll();
            //    BizObject.CacheData(key, obj);
            //}
            return obj;
        }
        /// <summary>
        /// Search SubCategory object in table SubCategory.
        /// </summary>
        /// <param name="t">Condition for Search.</param>

        /// <returns>List SubCategoryResult objects.</returns>

        public static List<SubCategoryResult> SearchSubCategorySomeCondition(SubCategory t)
        {
            return SubCategoryDao.SearchSubCategorySomeCondition(t);
        }
        /// <summary>
        /// Get a SubCategory data object by primary key. 
        /// </summary>
        /// <param name="subCategoryId" >This is primary key.</param>
        /// <returns>A SubCategory object.</returns>

        public static SubCategory Get(int subCategoryId,string cate)
        {
            SubCategory obj = null;
            //string key = "SubCategory_Get_" + string.Format("{0}", subCategoryId);
            //if (BizObject.Cache[key] != null)
            //{
            //    obj = (SubCategory)BizObject.Cache[key];
            //}
            //else
            //{
                obj = SubCategoryDao.Get(subCategoryId,cate);
            //    BizObject.CacheData(key, obj);
            //}
            return obj;
        }

        /// <summary>
        /// This function to Delete SubCategory object by primary key.
        /// </summary>
        /// <param name="subCategoryId" >This is primary key.</param>
        /// <returns>If succesful return True else  return False.</returns>

        public static bool Delete(int subCategoryId)
        {
           // BizObject.PurgeCacheItems("SubCategory");

            return SubCategoryDao.Delete(subCategoryId);
        }
        public static bool Delete(List<SubCategory> lstSub)
        {
           // BizObject.PurgeCacheItems("SubCategory");
            foreach (SubCategory objCate in lstSub)
            {
                SubCategoryDao.Delete(objCate.SubCategoryId);
            }
            return true;
        }
        public static bool Publish(SubCategory obj)
        {
            return SubCategoryDao.Publish(obj);
        }
        public static bool Order(SubCategory obj, int type)
        {
            return SubCategoryDao.Order(obj, type);
        }
        public static List<SubCategoryResult> GetAllByCategory(string categoryId)
        {
            List<SubCategoryResult> obj = null;
            //string key = "GetAllByCategory_" + categoryId;
            //if (BizObject.Cache[key] != null)
            //{
            //    obj = (List<SubCategoryResult>)BizObject.Cache[key];
            //}
            //else
            //{
                obj = SubCategoryDao.GetAllByCategory(categoryId);
            //    BizObject.CacheData(key, obj);
            //}
            return obj;
        }
        public static List<SubCategoryResult> GetDonViTinhByLoaiHangHoa(int maLoaiHangHoa)
        {
            if (maLoaiHangHoa <= 0)
                return null;
            return SubCategoryDao.GetDonViTinhByLoaiHangHoa(maLoaiHangHoa);
        }
        public static List<SubCategoryResult> GetDonViTinhByMatHang(string maMatHang)
        {
            return SubCategoryDao.GetDonViTinhByMatHang(maMatHang);
        }
    }
}